package com.hoshiicloud.goods.controller.storesys;

import com.hoshiicloud.auth.vo.TokenUsersVO;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.goods.service.ExtSpuService;
import com.hoshiicloud.goods.utils.UserInfoUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author qry
 * @date 2019/8/15 16:34
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/storesys/goods-manage")
@Api(value = "店铺后台商品管理", tags = {"店铺后台商品管理"})
public class StoreSysGoodsManageController {
    @Autowired
    private ExtSpuService extSpuService;

    @ApiOperation(value = "分页查询商品列表")
    @PostMapping("/getPage")//原地址  /goods/ext-spu/listExtSpuDisplays
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize",value = "每页条数",example = "10",dataType = "String"),
            @ApiImplicitParam(name = "pageNumber",value = "页码",example = "1",dataType = "String"),
            @ApiImplicitParam(name = "status",value = "上下架状态",example = "1",dataType = "int"),
            @ApiImplicitParam(name = "spuNo",value = "spu编码",example = "12212",dataType = "String"),
            @ApiImplicitParam(name = "title",value = "商品编码",example = "美味精品台蘑酱",dataType = "String"),
            @ApiImplicitParam(name = "categoryId",value = "三级类目ID",example = "1",dataType = "Long"),
            @ApiImplicitParam(name = "orderField",value = "排序字段",example = "salePrice",dataType = "String"),
            @ApiImplicitParam(name = "ordeType",value = "排序类型，asc-升序，desc-d降序",example = "desc",dataType = "String"),
    })
    public Response listExtSpuDisplays(@RequestBody Map<String, Object> map, HttpServletRequest rq) {
        TokenUsersVO user = UserInfoUtil.getUserInfo(rq);
        map.put("companyId", user.getCompanyId());
        map.put("platformId", user.getPlatId());
        map.put("storeId", user.getStoreId());
        return Response.data(extSpuService.listExtSpuDisplays(map));
    }



}
